package com.lzhsite.technology.designPattern.flyweight;
/*
	享元模式（Flyweight Pattern）主要用于减少创建对象的数量，以减少内存占用和提高性能。
	这种类型的设计模式属于结构型模式，它提供了减少对象数量从而改善应用所需的对象结构的方式。
	
	享元模式尝试重用现有的同类对象，如果未找到匹配的对象，则创建新对象。
*/
public class ClientForWebSiteDemo
{
    public static void main(String[] args)
    {
        WebSiteFactory webSiteFactory = new WebSiteFactory();

        WebSite webSite1 = webSiteFactory.getWebSiteCategory("产品展示");
        webSite1.setUser(new User("小菜"));

        WebSite webSite2 = webSiteFactory.getWebSiteCategory("产品展示");
        webSite1.setUser(new User("大鸟"));

        WebSite webSite3 = webSiteFactory.getWebSiteCategory("产品展示");
        webSite1.setUser(new User("娇娇"));

        WebSite webSite4 = webSiteFactory.getWebSiteCategory("产品展示");
        webSite1.setUser(new User("桃谷六仙"));

        WebSite webSite5 = webSiteFactory.getWebSiteCategory("产品展示");
        webSite1.setUser(new User("南海神鄂"));
    }
}
